package com.smarthealthcare.followup.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smarthealthcare.common.annotation.Log;
import com.smarthealthcare.common.core.controller.BaseController;
import com.smarthealthcare.common.core.domain.AjaxResult;
import com.smarthealthcare.common.enums.BusinessType;
import com.smarthealthcare.followup.domain.Followup;
import com.smarthealthcare.followup.service.IFollowupService;
import com.smarthealthcare.common.utils.poi.ExcelUtil;
import com.smarthealthcare.common.core.page.TableDataInfo;

/**
 * followupController
 * 
 * @author ruoyi
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/followup/followup")
public class FollowupController extends BaseController
{
    @Autowired
    private IFollowupService followupService;

    /**
     * 查询followup列表
     */
    @PreAuthorize("@ss.hasPermi('followup:followup:list')")
    @GetMapping("/list")
    public TableDataInfo list(Followup followup)
    {
        startPage();
        List<Followup> list = followupService.selectFollowupList(followup);
        return getDataTable(list);
    }

    /**
     * 导出followup列表
     */
    @PreAuthorize("@ss.hasPermi('followup:followup:export')")
    @Log(title = "followup", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Followup followup)
    {
        List<Followup> list = followupService.selectFollowupList(followup);
        ExcelUtil<Followup> util = new ExcelUtil<Followup>(Followup.class);
        util.exportExcel(response, list, "followup数据");
    }

    /**
     * 获取followup详细信息
     */
    @PreAuthorize("@ss.hasPermi('followup:followup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(followupService.selectFollowupById(id));
    }

    /**
     * 新增followup
     */
    @PreAuthorize("@ss.hasPermi('followup:followup:add')")
    @Log(title = "followup", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Followup followup)
    {
        return toAjax(followupService.insertFollowup(followup));
    }

    /**
     * 修改followup
     */
    @PreAuthorize("@ss.hasPermi('followup:followup:edit')")
    @Log(title = "followup", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Followup followup)
    {
        return toAjax(followupService.updateFollowup(followup));
    }

    /**
     * 删除followup
     */
    @PreAuthorize("@ss.hasPermi('followup:followup:remove')")
    @Log(title = "followup", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(followupService.deleteFollowupByIds(ids));
    }
}
